package com.itheima.datasource.druid;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 德鲁伊数据库连接池
 *      步骤：
 *          导入 jar 包
 *          定义配置文件  (properties) 名称任意 因为不会自动加载 需要手动
 */
public class DruidDemo1 {

    public static void main(String[] args) throws Exception {
        //获取连接对象
        InputStream resourceAsStream = DruidDemo1.class.getClassLoader().getResourceAsStream("druid.properties");
        Properties properties = new Properties();
        properties.load(resourceAsStream);
        DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);
        System.out.println(dataSource);

    }
}
